
package com.jf.cloud.api.product.feign;

import com.jf.cloud.api.product.bo.SpuSimpleBO;
import com.jf.cloud.common.feign.FeignInsideAuthConfig;
import com.jf.cloud.common.product.bo.EsProductBO;
import com.jf.cloud.common.product.dto.SpuDTO;
import com.jf.cloud.common.product.vo.*;
import com.jf.cloud.common.product.vo.search.ProductSearchVO;
import com.jf.cloud.common.product.vo.search.SpuAdminVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zz
 * @date 2020/11/12
 */
@FeignClient(value = "jfcloud-product",contextId = "spu")
public interface SpuFeignClient {

    /**
     * 通过spuId需要搜索的商品
     * @param spuId spuid
     * @return 商品信息(spuId,name,mainImgUrl)
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/getById")
    ServerResponseEntity<SpuVO> getById(@RequestParam("spuId") Long spuId);

    /**
     * 通过spuId需要搜索的商品
     * @param spuId spuid
     * @return 商品信息(spuId,name,mainImgUrl)
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/getDetailById")
    ServerResponseEntity<SpuVO> getDetailById(@RequestParam("spuId") Long spuId);

    /**
     * 通过spuId需要搜索的商品
     * @param spuId spuId
     * @param skuId skuId
     * @param supplierSpu 是否供应商商品
     * @return 商品信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/getSpuAndSkuAndRateById")
    ServerResponseEntity<SpuAndSkuVO> getSpuAndSkuAndRateById(@RequestParam("spuId") Long spuId,@RequestParam("skuId") Long skuId,@RequestParam("supplierSpu") Boolean supplierSpu);

    /**
     * 根据店铺id或者商品id或者为空直接获取可以参与秒杀活动的商品列表
     * @param spuId spuId
     * @param shopId 店铺id
     * @return 商品信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/listCanSeckillProd")
    ServerResponseEntity<List<SpuVO>> listCanSeckillProd(@RequestParam(value = "isFailure",defaultValue = "0") Long spuId,
                                                               @RequestParam(value = "shopId") Long shopId);

    /**
     * 根据商品编码获取商品列表
     * @param partyCodeList 商品编码
     * @return 商品信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/listPurchaseSpuVOByPartyCodeList")
    ServerResponseEntity<List<PurchaseSpuVO>> listPurchaseSpuByPartyCodeList(@RequestParam(value = "partyCodeList") List<String> partyCodeList,
                                                                             @RequestParam("shopId") Long shopId);

    /**
     * 获取商品活动信息
     * @param shopId
     * @param spuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/spuActivityBySpuId")
    ServerResponseEntity<SpuActivityAppVO> spuActivityBySpuId(@RequestParam("shopId")Long shopId, @RequestParam("spuId") Long spuId);

    /**
     * 下线spu
     * @param shopId
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/offlineSpuByShopId")
    ServerResponseEntity<Void> offlineSpuByShopId(@RequestBody Long shopId);

    /**
     * 根据店铺id下线店铺商品（批量）
     * @param shopIds 店铺id集合
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/offlineSpuByShopIds")
    ServerResponseEntity<Void> offlineSpuByShopIds(@RequestBody List<Long> shopIds);

    /**
     * 根据供应商Id下线供应商店铺的商品
     * @param supplierId
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/offlineSpuBySupplierId")
    ServerResponseEntity<Void> offlineSpuBySupplierId(@RequestParam("supplierId") Long supplierId);

    /**
     * 获取spu和sku信息
     * @param spuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/getSpuAndSkuBySpuId")
    ServerResponseEntity<SpuVO> getSpuAndSkuBySpuId(@RequestParam("spuId") Long spuId);

    /**
     * 更新商品类型
     * @param spuDTO
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/changeSpuType")
    ServerResponseEntity<Void> changeSpuType(@RequestBody SpuDTO spuDTO);

    /**
     * 根据运费id获取商品数量
     * @param transportId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/countByTransportId")
    ServerResponseEntity<Integer>  countByTransportId(@RequestParam("spuId") Long transportId);

    /**
     * 删除商品活动缓存
     * @param shopId null:代表所有的店铺  not null: 指定到具体店铺（若不指定spuIds,则按店铺、平台清除商品的缓存）
     * @param spuIds 商品id列表不为空代表有指定删除缓存的商品列表，就不进行全店铺/平台的商品缓存清除
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/removeSpuActivityCache")
    void removeSpuActivityCache(@RequestParam("shopId") Long shopId, @RequestParam("spuIds") List<Long> spuIds);

    /**
     * 将商品变为普通商品
     * @param spuIds 商品id
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/changeToNormalSpu")
    void changeToNormalSpu(@RequestBody List<Long> spuIds);

    /**
     * 根据用户id查询商品收藏数量
     * @param userId 用户id
     * @return 商品收藏数量
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/countByUserId")
    ServerResponseEntity<Integer> countByUserId(@RequestParam("userId") Long userId);

    /**
     * 根据商品id列表获取商品名称列表
     * @param spuIds
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/spu/listSpuNameByIds")
    ServerResponseEntity<List<SpuVO>> listSpuNameBySpuIds(@RequestBody List<Long> spuIds);

    /**
     * 根据商品id列表获取商品列表
     * @param spuIds
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/listSpuBySpuIds")
    ServerResponseEntity<List<SpuVO>> listSpuBySpuIds(@RequestBody List<Long> spuIds);

    /**
     * 根据店铺id列表更新商品更新时间
     * @param shopIds
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/updateSpuUpdateTime")
    ServerResponseEntity<Void> updateSpuUpdateTimeByShopIds(@RequestBody List<Long> shopIds, @RequestParam("sysType") Integer sysType);

    /**
     * 失效商品活动信息，不需要下架商品
     * @param shopIds
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/offlineSpuActivityByShopIds")
    ServerResponseEntity<Void> offlineSpuActivityByShopIds(@RequestBody List<Long> shopIds);

    /**
     * 根据基本信息查询商品列表
     * @param spuSimpleBO
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/listSimple")
    ServerResponseEntity<List<SpuSimpleBO>> listSimple(@RequestBody SpuSimpleBO spuSimpleBO);

    /**
     * 根据基本信息查询商品列表（包括删除商品）
     * @param spuSimpleBO
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/listSimples")
    ServerResponseEntity<List<SpuSimpleBO>> listSimples(@RequestBody SpuSimpleBO spuSimpleBO);


    /**
     * 获取指定sku的价格
     * @param skuIds
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/listSkuPriceByIds")
    ServerResponseEntity<List<SkuVO>> listSkuPriceByIds(@RequestBody List<Long> skuIds);

    /**
     * 根据店铺id获取所有商品id
     * @param shopId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/listSpuIdsByShopId")
    ServerResponseEntity<List<Long>> listSpuIdsByShopId(@RequestParam("shopId") Long shopId);

    /**
     * 根据spuIds校验状态
     * @param spuIds
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/sku/checkSpuStatus")
    ServerResponseEntity<?> checkSpuStatus(@RequestBody List<Long> spuIds);

    /**
     * 根据供应商id和商品规格id获取商品信息
     * @param skuList 商品规格
     * @param supplierId 供应商id
     * @return 商品信息
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/listSpuAndSkuById")
    ServerResponseEntity<List<SpuAndSkuVO>> listSpuAndSkuById(@RequestBody List<SkuVO> skuList, @RequestParam("shopId")Long supplierId);

    /**
     * 根据店铺id和供应商商品id判断店铺是否代销了
     * @param spuAdminVOS
     * @param shopId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/isCommissionByShopIdAndSpuId")
    ServerResponseEntity<List<SpuAdminVO>> isCommissionByShopIdAndSpuId(@RequestBody List<SpuAdminVO> spuAdminVOS, @RequestParam("shopId") Long shopId);

    /**
     * 当供货价高于代销价时下架商品(sku供货价）
     * @param skuId
     * @param price
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/soldOutSpu")
    ServerResponseEntity<Void> soldOutSpu(@RequestParam("skuId") Long skuId, @RequestParam("price") Long price);

    /**
     * 根据代销商品id列表获取供货价格信息
     * @param spuIds
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/getSupplyPrice")
    ServerResponseEntity<List<SpuVO>> getSupplyPrice(@RequestBody List<Long> spuIds);

    /**
     * 供应商修改供货价时修改代销商品价格
     * @param supplierSpuId
     * @param price
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/soldOutSpuBySpu")
    ServerResponseEntity<Void> soldOutSpuBySpu(@RequestParam("supplierSpuId") Long supplierSpuId, @RequestParam("price") Long price, @RequestParam("marketPriceFee") Long marketPriceFee);

    /**
     * 供应商改变供应商品状态时代销商品同步状态
     * @param supplierSpuId
     * @param status
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/supplierUpdateSpuStatus")
    ServerResponseEntity<Void> supplierUpdateSpuStatus(@RequestParam("supplierSpuId") Long supplierSpuId,@RequestParam("status") Integer status);

    /**
     * 获取代销商品 供应商商品更新后代销商品是否已同步更新 值
     * @param spuIds
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/getSpuIsSynUpdate")
    ServerResponseEntity<List<SpuVO>> getSpuIsSynUpdate(@RequestBody List<Long> spuIds);

    /**
     * 供应商商品变更后对应下架不同类型的代销商品
     * @param supplierSpuId
     * @param commissionSpuOffType
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/supplierSpuUpdateLaterOffSpu")
    ServerResponseEntity<Void> supplierSpuUpdateLaterOffSpu(@RequestParam("supplierSpuId") Long supplierSpuId, @RequestParam("commissionSpuOffType") Integer commissionSpuOffType);

    /**
     * 供货价发生变化、sku种类增加，商家是手动设价，下架商家的商品
     * @param supplierSpuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/skuUpdateLaterOperate")
    ServerResponseEntity<Void> skuUpdateLaterOperate(@RequestParam("supplierSpuId") Long supplierSpuId);

    /**
     * 如果重量体积发生变化，商品是商家发货，下架商家商品
     * @param supplierSpuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/skuWeightOrVolumeUpdateOperate")
    ServerResponseEntity<Void> skuWeightOrVolumeUpdateOperate(@RequestParam("supplierSpuId") Long supplierSpuId);

    /**
     * 如果sku增加之后代销商品同步
     * @param supplierSpuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/skuAddOperate")
    ServerResponseEntity<Void> skuAddOperate(@RequestParam("supplierSpuId") Long supplierSpuId);

    /**
     * 验证 当商家设置了手动设价--供货价高于售价自动下架商品 发布的商品售价是否低于供货价 低于就下架代销商品
     * @param esProductBO
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/feePriceUnderSupplyPrice")
    ServerResponseEntity<Void> feePriceUnderSupplyPrice(@RequestBody EsProductBO esProductBO);


    /**
     * 供应商变更了商品信息，下架手动设价的代销商品
     * @param supplierSpuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/soldOutManualPriceCommissionSpu")
    ServerResponseEntity<Void> soldOutManualPriceCommissionSpu(@RequestParam("supplierSpuId")Long supplierSpuId,@RequestParam("type") Integer type,@RequestParam("isFiltration") Integer isFiltration);

    /**
     * 供应商品sku增加或者删除处理代销商品sku
     * @param supplierSpuId
     * @param skuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/supplierSkuAddOrDeleteLaterOperate")
    ServerResponseEntity<Void> supplierSkuAddOrDeleteLaterOperate(@RequestParam("supplierSpuId")Long supplierSpuId,@RequestParam("skuId") Long skuId);


    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/changeSynUpdate")
    ServerResponseEntity<Void> changeSynUpdate(@RequestParam("supplierSpuId")Long supplierSpuId);

    /**
     * 商家修改代销设置，更新已导入的代销商品价格
     * @param shopId
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/updateManualPriceCommissionSpuPrice")
    ServerResponseEntity<Void> updateManualPriceCommissionSpuPrice(@RequestParam("shopId")Long shopId);

    /**
     * 商家端获取商品信息列表时 检查代销商品基本信息是否改变，如果改变了显示商家自己商品信息，没有改变则显示供应商信息
     * @param spuAdminVOS
     * @return
     */
    @PostMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/checkCommissionSpuIsUpdateMsg")
    ServerResponseEntity<List<SpuAdminVO>> checkCommissionSpuIsUpdateMsg(@RequestBody List<SpuAdminVO> spuAdminVOS);

    /**
     * 商家端获取商品信息列表时 检查代销商品基本信息是否改变，如果改变了显示商家自己商品信息，没有改变则显示供应商信息
     * @param productSearchVOS
     * @return
     */
    @PostMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/usCheckCommissionSpuIsUpdateMsg")
    ServerResponseEntity<List<ProductSearchVO>> usCheckCommissionSpuIsUpdateMsg(@RequestBody List<ProductSearchVO> productSearchVOS);

    /**
     * 秒杀支付成功后，更新商品的销量
     * @param spuId
     * @param prodCount
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/updateSaleNumBySeckillOrder")
    ServerResponseEntity<Void>updateSaleNumBySeckillOrder(@RequestParam("spuId")Long spuId, @RequestParam("prodCount")Integer prodCount);

    /**
     * 根据商品id列表获取商品列表(无需授权）
     * @param spuIds
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_URL_PREFIX + "/insider/spu/listSpuBySpuIdsNo")
    ServerResponseEntity<List<SpuVO>> listSpuBySpuIdsNo(@RequestBody List<Long> spuIds);

    /**
     * 根据spuIds获取商品信息
     * @param spuIdS
     * @return mainImgUrl
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_INSIDER_URL_PREFIX + "/spu/getDetailBySpuIds")
    ServerResponseEntity<List<SpuVO>> getDetailBySpuIds(@RequestParam("spuIdS")List<Long> spuIdS);

    /**
     * 根据供应商id列表下架商品
     * @param supplierIdsToStop
     * @return
     */
    @PutMapping(value = FeignInsideAuthConfig.FEIGN_INSIDER_URL_PREFIX + "/spu/batchChangeSpuStatusBySupplierIds")
    ServerResponseEntity<Void> batchChangeSpuStatusToDisableBySupplierIds(@RequestParam("supplierIds") List<Long> supplierIdsToStop);

    /**
     * 供应商品更新品牌或者排序时,同步更新代销商品的品牌或排序
     * @param brandId
     * @param seq
     * @param supplierSpuId
     * @return
     */
    @GetMapping(value = FeignInsideAuthConfig.FEIGN_INSIDER_URL_PREFIX + "/spu/batchChangeSpuStatusBySupplierIds")
    ServerResponseEntity<Void> syncUpdateCommissionSpuBrandOrSeq(@RequestParam("brandId") Long brandId, @RequestParam("seq") Integer seq,
                                                                 @RequestParam("supplierId") Long supplierSpuId);


    /**
     * 添加采购订单时未导入的供应商品自动导入
     * @param spuVOS
     * @param sysType
     * @param userId
     * @return
     */
    @PostMapping(value = FeignInsideAuthConfig.FEIGN_INSIDER_URL_PREFIX + "/spu/voluntarilyImportSupplierSpu")
    ServerResponseEntity<Void> voluntarilyImportSupplierSpu(@RequestBody List<SpuVO> spuVOS,@RequestParam("sysType") Integer sysType,
                                                            @RequestParam("userId") Long userId);

    /**
     * 根据店铺id更新商品
     */
    @GetMapping(FeignInsideAuthConfig.FEIGN_INSIDER_URL_PREFIX + "/insider/product/updateSpuByShopId")
    ServerResponseEntity<Void> updateSpuByShopId(@RequestParam("shopId") Long shopId,@RequestParam("sysType") Integer sysType);
}
